/*
 * ESNull.java - ScriptME
 * 
 * Copyright (c) 2009 Cesar Henriques <cesar at alttab.com.ar>.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Based on FESI Project
 * 
 * Contributors:
 * 	Jean-Marc Lugrin - initial API and implementation
 * 	Cesar Henriques <cesar at alttab.com.ar> - J2ME Porting and Extensions
 */
package org.scriptme.ecmascript.data;

/**
 * Implements the NULL EcmaScript primitive value
 * <P>
 * There is only one value of this type which is referenced by ESNull.theNull.
 * In general it is not identical for a routine to return ESNull, ESUndefined or
 * the java null. They all have different purposes.
 */
public final class ESNull extends ESPrimitive {

	/** the READ-ONLY null value. */
	public static ESNull theNull = new ESNull();

	/**
	 * Instantiates a new eS null.
	 */
	private ESNull() {
	}

	// overrides
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.scriptme.ecmascript.data.ESValue#toDetailString()
	 */
	public String toDetailString() {
		return "ES:<null>";
	}

	// overrides
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.scriptme.ecmascript.data.ESValue#getTypeOf()
	 */
	public int getTypeOf() {
		return EStypeNull;
	}

	// overrides
	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return "null";
	}

	// overrides
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.scriptme.ecmascript.data.ESValue#getTypeofString()
	 */
	public String getTypeofString() {
		return "object";
	}

	// overrides
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.scriptme.ecmascript.data.ESValue#doubleValue()
	 */
	public double doubleValue() {
		return 0;
	}

	// overrides
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.scriptme.ecmascript.data.ESValue#booleanValue()
	 */
	public boolean booleanValue() {
		return false;
	}

	// overrides
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.scriptme.ecmascript.data.ESValue#toJavaObject()
	 */
	public Object toJavaObject() {
		return null;
	}
}
